/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package byzantine.controls.listeners;

import byzantine.ByzantineModel;
import byzantine.controls.SimulationSetupControls;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;

/**
 *
 * @author rpathan
 */
public class GeneralTypeListener implements ActionListener {

    SimulationSetupControls setupControls;

    public GeneralTypeListener(SimulationSetupControls setupControls) {
        this.setupControls = setupControls;
    }

    public void actionPerformed(ActionEvent e) {
        JComboBox cb = (JComboBox) e.getSource();
        if (cb.getSelectedItem() == null) {
            return;
        }
        
        String selectedItem = cb.getSelectedItem().toString();
        
        if (selectedItem.equals(ByzantineModel.COMMANDER)) {
            setupControls.setSelectedItem(ByzantineModel.COMMANDER);
        } else if (selectedItem.equals(ByzantineModel.COMMANDER_REBEL)) {
            setupControls.setSelectedItem(ByzantineModel.COMMANDER_REBEL);
        } else if (selectedItem.equals(ByzantineModel.GENERAL)) {
            setupControls.setSelectedItem(ByzantineModel.GENERAL);
        } else if (selectedItem.equals(ByzantineModel.GENERAL_REBEL)) {
            setupControls.setSelectedItem(ByzantineModel.GENERAL_REBEL);
        }
    }
}
